package com.web.java0328springboot.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.web.java0328springboot.entity.Course;

import com.web.java0328springboot.entity.PageVO;
import com.web.java0328springboot.mapper.CourseMapper;
import com.web.java0328springboot.service.CourseService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lenovo
 * @Description
 * @Date2025/3/29 下午4:42
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {

    @Resource
    private CourseMapper courseMapper;

    @Override
    public PageVO getCoursePage(Integer current, Integer pageSize) {
        // 创建分页对象
        IPage<Course> page = courseMapper.selectCoursePage(new Page<>(current,pageSize) );

        // 调用Mapper查询分页数据
        PageVO pageVO = new PageVO(page.getCurrent(), page.getSize(), page.getTotal(), page.getRecords());
        // 返回自定义分页结果
        return pageVO;
    }

}
